from flask import Flask, jsonify, request
from flask_cors import CORS
import socket


app = Flask(__name__)
CORS(app, resources={r"/*": {"origins": "*"}})


@app.route('/get-ip', methods=['POST'])
def get_ip():
    data = request.get_json()
    domain = data.get('domain')
    try:
        ip = socket.gethostbyname(domain)
        return jsonify({'ip': ip})
    except Exception as e:
        return jsonify({'error': str(e)})


if __name__ == '__main__':
    app.run()
